/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.polytec.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Felix
 */
@Entity
@Table(name = "commande")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Commande.findAll", query = "SELECT c FROM Commande c"),
    @NamedQuery(name = "Commande.findByIdCommande", query = "SELECT c FROM Commande c WHERE c.idCommande = :idCommande"),
    @NamedQuery(name = "Commande.findByNombreDUnite", query = "SELECT c FROM Commande c WHERE c.nombreDUnite = :nombreDUnite"),
    @NamedQuery(name = "Commande.findByPrixDUnite", query = "SELECT c FROM Commande c WHERE c.prixDUnite = :prixDUnite"),
    @NamedQuery(name = "Commande.findBySommeCommande", query = "SELECT c FROM Commande c WHERE c.sommeCommande = :sommeCommande")})
public class Commande implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_commande")
    private Integer idCommande;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nombre_d_unite")
    private int nombreDUnite;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prix_d_unite")
    private double prixDUnite;
    @Basic(optional = false)
    @NotNull
    @Column(name = "somme_commande")
    private double sommeCommande;
    @JoinColumn(name = "id_produit", referencedColumnName = "id_produit")
    @ManyToOne(optional = false)
    private Produit idProduit;
    @JoinColumn(name = "id_panier", referencedColumnName = "id_panier")
    @ManyToOne
    private Panier idPanier;

    public Commande() {
    }

    public Commande(Integer idCommande) {
        this.idCommande = idCommande;
    }

    public Commande(Integer idCommande, int nombreDUnite, double prixDUnite, double sommeCommande) {
        this.idCommande = idCommande;
        this.nombreDUnite = nombreDUnite;
        this.prixDUnite = prixDUnite;
        this.sommeCommande = sommeCommande;
    }

    public Integer getIdCommande() {
        return idCommande;
    }

    public void setIdCommande(Integer idCommande) {
        this.idCommande = idCommande;
    }

    public int getNombreDUnite() {
        return nombreDUnite;
    }

    public void setNombreDUnite(int nombreDUnite) {
        this.nombreDUnite = nombreDUnite;
    }

    public double getPrixDUnite() {
        return prixDUnite;
    }

    public void setPrixDUnite(double prixDUnite) {
        this.prixDUnite = prixDUnite;
    }

    public double getSommeCommande() {
        return sommeCommande;
    }

    public void setSommeCommande(double sommeCommande) {
        this.sommeCommande = sommeCommande;
    }

    public Produit getIdProduit() {
        return idProduit;
    }

    public void setIdProduit(Produit idProduit) {
        this.idProduit = idProduit;
    }

    public Panier getIdPanier() {
        return idPanier;
    }

    public void setIdPanier(Panier idPanier) {
        this.idPanier = idPanier;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCommande != null ? idCommande.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commande)) {
            return false;
        }
        Commande other = (Commande) object;
        if ((this.idCommande == null && other.idCommande != null) || (this.idCommande != null && !this.idCommande.equals(other.idCommande))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.polytec.entities.Commande[ idCommande=" + idCommande + " ]";
    }
    
}
